﻿-- install membership service (full set)
aspnet_regsql -S 192.168.0.242 -d Membership -U membership -P membership -A all

--install membership service
aspnet_regsql -S 192.168.0.242 -d POS -U pos -P pos -A rw


-- Role's Permissions
CREATE TABLE [dbo].[PermissionsInRoles](
	[RoleId] [uniqueidentifier] NOT NULL,
	[MenuId] [int] NOT NULL,
	[ModuleId] [int] NOT NULL,
	[FuncId] [int] NOT NULL,
	[FlagName] [nvarchar](512) NULL,
 CONSTRAINT [PK_PermissionsInRoles] PRIMARY KEY CLUSTERED 
(
	[RoleId] ASC,
	[MenuId] ASC,
	[FuncId] ASC,
	[ModuleId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


--ALTER TABLE [dbo].[PermissionsInRoles]  WITH CHECK ADD  CONSTRAINT [FK_PermissionsInRoles_aspnet_Roles] FOREIGN KEY([RoleId])
--REFERENCES [dbo].[aspnet_Roles] ([RoleId])
--GO

--ALTER TABLE [dbo].[PermissionsInRoles] CHECK CONSTRAINT [FK_PermissionsInRoles_aspnet_Roles]
--GO




-- User's Permission
CREATE TABLE [dbo].[UsersInPermissions](
	[UserId] [uniqueidentifier] NOT NULL,
	[UserName] [nvarchar](256) NOT NULL,
	[MenuId] [int] NOT NULL,
	[ModuleId] [int] NOT NULL,
	[FuncId] [int] NOT NULL,
	[FlagName] [nvarchar](512) NULL,
 CONSTRAINT [PK_UsersInPermissions] PRIMARY KEY CLUSTERED 
(
	[UserName] ASC,
	[MenuId] ASC,
	[FuncId] ASC,
	[ModuleId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

--ALTER TABLE [dbo].[UsersInPermissions]  WITH CHECK ADD  CONSTRAINT [FK_UsersInPermissions_aspnet_Users] FOREIGN KEY([UserId])
--REFERENCES [dbo].[aspnet_Users] ([UserId])
--GO

--ALTER TABLE [dbo].[UsersInPermissions] CHECK CONSTRAINT [FK_UsersInPermissions_aspnet_Users]
--GO